/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.biblio.persistencias;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Héctor <UFG>
 */
@Entity
@Table(name = "solicitante", catalog = "mydb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Solicitante.findAll", query = "SELECT s FROM Solicitante s"),
    @NamedQuery(name = "Solicitante.findBySolId", query = "SELECT s FROM Solicitante s WHERE s.solId = :solId"),
    @NamedQuery(name = "Solicitante.findBySolNombre", query = "SELECT s FROM Solicitante s WHERE s.solNombre = :solNombre"),
    @NamedQuery(name = "Solicitante.findBySolApellidos", query = "SELECT s FROM Solicitante s WHERE s.solApellidos = :solApellidos"),
    @NamedQuery(name = "Solicitante.findBySolDireccion", query = "SELECT s FROM Solicitante s WHERE s.solDireccion = :solDireccion"),
    @NamedQuery(name = "Solicitante.findBySolTelefono", query = "SELECT s FROM Solicitante s WHERE s.solTelefono = :solTelefono"),
    @NamedQuery(name = "Solicitante.findBySolCorreo", query = "SELECT s FROM Solicitante s WHERE s.solCorreo = :solCorreo"),
    @NamedQuery(name = "Solicitante.findBySolFechaRes", query = "SELECT s FROM Solicitante s WHERE s.solFechaRes = :solFechaRes"),
    @NamedQuery(name = "Solicitante.findBySolEstado", query = "SELECT s FROM Solicitante s WHERE s.solEstado = :solEstado"),
    @NamedQuery(name = "Solicitante.findBySolLogId", query = "SELECT s FROM Solicitante s WHERE s.solLogId = :solLogId")})
public class Solicitante implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "sol_id")
    private Integer solId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "sol_nombre", nullable = false, length = 20)
    private String solNombre;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "sol_apellidos", nullable = false, length = 20)
    private String solApellidos;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "sol_direccion", nullable = false, length = 45)
    private String solDireccion;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 9)
    @Column(name = "sol_telefono", nullable = false, length = 9)
    private String solTelefono;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Pattern(regexp = ".[0-9a-zA-Z]+@.+[0-9a-zA-Z].[a-zA-Z][a-zA-Z]+", message = "Debes ingresar un correo válido [ejemplo@ejemplo.com]")
    @Column(name = "sol_correo", nullable = false, length = 45)
    private String solCorreo;
    @Basic(optional = false)
    @NotNull
    @Column(name = "sol_fecha_res", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date solFechaRes;
    @Lob
    @Column(name = "sol_foto")
    private byte[] solFoto;
    @Basic(optional = false)
    @NotNull
    @Column(name = "sol_estado", nullable = false)
    private boolean solEstado;
    @Basic(optional = false)
    @NotNull
    @Column(name = "sol_log_id", nullable = false)
    private int solLogId;
    @JoinColumn(name = "sol_rol_id", referencedColumnName = "rol_id", nullable = false)
    @ManyToOne(optional = false)
    private UsuarioRol solRolId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "prestIdSolicitante")
    private List<Prestamo> prestamoList;

    public Solicitante() {
    }

    public Solicitante(Integer solId) {
        this.solId = solId;
    }

    public Solicitante(Integer solId, String solNombre, String solApellidos, String solDireccion, String solTelefono, String solCorreo, Date solFechaRes, boolean solEstado, int solLogId) {
        this.solId = solId;
        this.solNombre = solNombre;
        this.solApellidos = solApellidos;
        this.solDireccion = solDireccion;
        this.solTelefono = solTelefono;
        this.solCorreo = solCorreo;
        this.solFechaRes = solFechaRes;
        this.solEstado = solEstado;
        this.solLogId = solLogId;
    }

    public Integer getSolId() {
        return solId;
    }

    public void setSolId(Integer solId) {
        this.solId = solId;
    }

    public String getSolNombre() {
        return solNombre;
    }

    public void setSolNombre(String solNombre) {
        this.solNombre = solNombre;
    }

    public String getSolApellidos() {
        return solApellidos;
    }

    public void setSolApellidos(String solApellidos) {
        this.solApellidos = solApellidos;
    }

    public String getSolDireccion() {
        return solDireccion;
    }

    public void setSolDireccion(String solDireccion) {
        this.solDireccion = solDireccion;
    }

    public String getSolTelefono() {
        return solTelefono;
    }

    public void setSolTelefono(String solTelefono) {
        this.solTelefono = solTelefono;
    }

    public String getSolCorreo() {
        return solCorreo;
    }

    public void setSolCorreo(String solCorreo) {
        this.solCorreo = solCorreo;
    }

    public Date getSolFechaRes() {
        return solFechaRes;
    }

    public void setSolFechaRes(Date solFechaRes) {
        this.solFechaRes = solFechaRes;
    }

    public byte[] getSolFoto() {
        return solFoto;
    }

    public void setSolFoto(byte[] solFoto) {
        this.solFoto = solFoto;
    }

    public boolean getSolEstado() {
        return solEstado;
    }

    public void setSolEstado(boolean solEstado) {
        this.solEstado = solEstado;
    }

    public int getSolLogId() {
        return solLogId;
    }

    public void setSolLogId(int solLogId) {
        this.solLogId = solLogId;
    }

    public UsuarioRol getSolRolId() {
        return solRolId;
    }

    public void setSolRolId(UsuarioRol solRolId) {
        this.solRolId = solRolId;
    }

    @XmlTransient
    public List<Prestamo> getPrestamoList() {
        return prestamoList;
    }

    public void setPrestamoList(List<Prestamo> prestamoList) {
        this.prestamoList = prestamoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (solId != null ? solId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Solicitante)) {
            return false;
        }
        Solicitante other = (Solicitante) object;
        if ((this.solId == null && other.solId != null) || (this.solId != null && !this.solId.equals(other.solId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return solApellidos + ", " + solNombre;
    }
    
}
